package cn.itcast.hotel.constants;
//创建库中的表结构，是否参与分词，倒排索引，子字段type使用object类

/**
 * elasticssearch简称es，
 * es底层基于lucene实现，只能用java开发
 * kibana数据可视化工具，和es共用一个网络，就可以连接起来
 * - ik_smart：智能切分，粗粒度
 * - ik_max_word：最细切分，细粒度
 * @两次分词：1.在进行增删改时，会进行分词，形成一个b+tree 2.在模糊查询时，首先会将用户输入内容进行分词，然后根据词条找到id
 * 拿到id之后再去正向索引中通过id查询
 * 总结:elasticsearch,不支持事务acid,在模糊查询时比mysql查询快,mysql在模糊查询时会一行一行的查询,对比,效率比较慢.
 */
public class HotelConstants {
    public static final String MAPPING_TEMPLATE = "{\n" +
      "  \"settings\": {\n" +
      "    \"analysis\": {\n" +
      "      \"analyzer\": {\n" +
      "        \"text_anlyzer\": {\n" +
      "          \"tokenizer\": \"ik_max_word\",\n" +
      "          \"filter\": \"py\"\n" +
      "        },\n" +
      "        \"completion_analyzer\": {\n" +
      "          \"tokenizer\": \"keyword\",\n" +
      "          \"filter\": \"py\"\n" +
      "        }\n" +
      "      },\n" +
      "      \"filter\": {\n" +
      "        \"py\": {\n" +
      "          \"type\": \"pinyin\",\n" +
      "          \"keep_full_pinyin\": false,\n" +
      "          \"keep_joined_full_pinyin\": true,\n" +
      "          \"keep_original\": true,\n" +
      "          \"limit_first_letter_length\": 16,\n" +
      "          \"remove_duplicated_term\": true,\n" +
      "          \"none_chinese_pinyin_tokenize\": false\n" +
      "        }\n" +
      "      }\n" +
      "    }\n" +
      "  },\n" +
      "  \"mappings\": {\n" +
      "    \"properties\": {\n" +
      "      \"id\":{\n" +
      "        \"type\": \"keyword\"\n" +
      "      },\n" +
      "      \"name\":{\n" +
      "        \"type\": \"text\",\n" +
      "        \"analyzer\": \"text_anlyzer\",\n" +
      "        \"search_analyzer\": \"ik_smart\",\n" +
      "        \"copy_to\": \"all\"\n" +
      "      },\n" +
      "      \"address\":{\n" +
      "        \"type\": \"keyword\",\n" +
      "        \"index\": false\n" +
      "      },\n" +
      "      \"price\":{\n" +
      "        \"type\": \"integer\"\n" +
      "      },\n" +
      "      \"score\":{\n" +
      "        \"type\": \"integer\"\n" +
      "      },\n" +
      "      \"brand\":{\n" +
      "        \"type\": \"keyword\",\n" +
      "        \"copy_to\": \"all\"\n" +
      "      },\n" +
      "      \"city\":{\n" +
      "        \"type\": \"keyword\"\n" +
      "      },\n" +
      "      \"starName\":{\n" +
      "        \"type\": \"keyword\"\n" +
      "      },\n" +
      "      \"business\":{\n" +
      "        \"type\": \"keyword\",\n" +
      "        \"copy_to\": \"all\"\n" +
      "      },\n" +
      "      \"location\":{\n" +
      "        \"type\": \"geo_point\"\n" +
      "      },\n" +
      "      \"pic\":{\n" +
      "        \"type\": \"keyword\",\n" +
      "        \"index\": false\n" +
      "      },\n" +
      "      \"all\":{\n" +
      "        \"type\": \"text\",\n" +
      "        \"analyzer\": \"text_anlyzer\",\n" +
      "        \"search_analyzer\": \"ik_smart\"\n" +
      "      },\n" +
      "      \"suggestion\":{\n" +
      "          \"type\": \"completion\",\n" +
      "          \"analyzer\": \"completion_analyzer\"\n" +
      "      }\n" +
      "    }\n" +
      "  }\n" +
      "}";
}